<?php
	$data = array();
	$data['title'] = "Đăng nhập";
	$db = new Model_muser;
	if(isset($_POST['type'])){
		$user = $_POST['username'];
		$pass = md5($_POST['password']);
		if($user == "" || $_POST['password'] == ""){
			echo 1;
			die();
		}else{
			$data = $db->check_login($user,$pass);
			if($data == FALSE){
				echo "2";
			}else{
				session_start();
				$_SESSION['ses_userid'] = $data['user_id'];
				$_SESSION['ses_users'] = $data['user_name'];
				$_SESSION['ses_level'] = $data['user_level'];
				echo "3";
			}
			//debug($_SESSION['ses_user']);
		}die();
	}
	$data['template'] = "main_home/login_view";
	loadview("layout",$data);
?>